import {View, Image} from '@tarojs/components'
import {AtButton} from 'taro-ui'
import Taro from "@tarojs/taro";
import "taro-ui/dist/style/components/button.scss" // 按需引入
import backgroudImage from '../../static/backgroundImage.jpg'
import './index.scss'
import GlobalFooter from "../../components/GlobalFooter";
import getBestQuestionResult from "../../components/utils/getBestQuestionResult";
import questionResults from '../../data/question_results.json';
import questions from '../../data/questions.json';

const toAnswer: () => void = () => {
    Taro.reLaunch({
        url: '/pages/index/index',
    })
}


export default () => {

  const resultList = Taro.getStorageSync("questionResultList")
  const result = getBestQuestionResult(resultList,questions,questionResults)

    return (

        <View className='index'>
            <View className='at-article__h1 title'>
              {result.resultName}
            </View>
            <View className='at-article__h2 describe'>
              {result.resultDesc}
            </View>
            <AtButton
              type='secondary'
              className='entryButton'
              size="normal" circle
              onClick={toAnswer}
            >返回主页
            </AtButton>
            <Image src={backgroudImage} style={{width: "100%"}} mode="aspectFill" />
            <GlobalFooter></GlobalFooter>
        </View>
    )

}
